{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-0.78545741 -0.32901548  0.30162305 -0.44569952  0.35459141]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "a = np.random.randn(5)\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5,)\n"
     ]
    }
   ],
   "source": [
    "print(a.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-0.78545741 -0.32901548  0.30162305 -0.44569952  0.35459141]\n"
     ]
    }
   ],
   "source": [
    "print(a.T)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5,)\n"
     ]
    }
   ],
   "source": [
    "print(a.T.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### a.shape == a.T.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.1405541189946087\n"
     ]
    }
   ],
   "source": [
    "print(np.dot(a, a.T))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.1405541189946087\n"
     ]
    }
   ],
   "source": [
    "print(np.dot(a.T, a))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### np.dot(a, a.T) == np.dot(a.T, a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5, 1)\n",
      "[[0.95188069]\n",
      " [0.02162932]\n",
      " [0.31903488]\n",
      " [0.84268715]\n",
      " [0.93512575]]\n"
     ]
    }
   ],
   "source": [
    "a = np.random.rand(5,1)\n",
    "print(a.shape)\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1, 5)\n",
      "[[0.95188069 0.02162932 0.31903488 0.84268715 0.93512575]]\n"
     ]
    }
   ],
   "source": [
    "print(a.T.shape)\n",
    "print(a.T)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[9.06076852e-01 2.05885328e-02 3.03683138e-01 8.02137630e-01\n",
      "  8.90128146e-01]\n",
      " [2.05885328e-02 4.67827515e-04 6.90050765e-03 1.82267507e-02\n",
      "  2.02261348e-02]\n",
      " [3.03683138e-01 6.90050765e-03 1.01783252e-01 2.68846591e-01\n",
      "  2.98337728e-01]\n",
      " [8.02137630e-01 1.82267507e-02 2.68846591e-01 7.10121638e-01\n",
      "  7.88018456e-01]\n",
      " [8.90128146e-01 2.02261348e-02 2.98337728e-01 7.88018456e-01\n",
      "  8.74460168e-01]]\n"
     ]
    }
   ],
   "source": [
    "print(np.dot(a, a.T))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 遇到(5,)这种的向量，使用reshape(5,1)方法"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
